package cc.fs.zhihuapp.model;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.Arrays;

/**
 * Created by fostion on 2015/8/18.
 */
public class News implements Parcelable{

    boolean isTag = false;
    String id;
    String title;
    String ga_prefix;
    String type;
    boolean multipic;
    String images[];
    String image;

    public News(boolean isTag, String title) {
        this.isTag = isTag;
        this.title = title;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String[] getImages() {
        return images;
    }

    public void setImages(String[] images) {
        setIsTag(false);
    }

    public boolean getMultipic() {
        return multipic;
    }

    public void setMultipic(boolean multipic) {
        this.multipic = multipic;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getTitle() {
        return title;
    }

    public boolean isTag() {
        return isTag;
    }

    public void setIsTag(boolean isTag) {
        this.isTag = isTag;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getGa_prefix() {
        return ga_prefix;
    }

    public void setGa_prefix(String ga_prefix) {
        this.ga_prefix = ga_prefix;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    @Override
    public String toString() {
        return "News{" +
                "isTag=" + isTag +
                ", id='" + id + '\'' +
                ", title='" + title + '\'' +
                ", ga_prefix='" + ga_prefix + '\'' +
                ", type='" + type + '\'' +
                ", multipic=" + multipic +
                ", images=" + Arrays.toString(images) +
                ", image='" + image + '\'' +
                '}';
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeByte(isTag ? (byte) 1 : (byte) 0);
        dest.writeString(this.id);
        dest.writeString(this.title);
        dest.writeString(this.ga_prefix);
        dest.writeString(this.type);
        dest.writeByte(multipic ? (byte) 1 : (byte) 0);
        dest.writeStringArray(this.images);
        dest.writeString(this.image);
    }

    protected News(Parcel in) {
        this.isTag = in.readByte() != 0;
        this.id = in.readString();
        this.title = in.readString();
        this.ga_prefix = in.readString();
        this.type = in.readString();
        this.multipic = in.readByte() != 0;
        this.images = in.createStringArray();
        this.image = in.readString();
    }

    public static final Creator<News> CREATOR = new Creator<News>() {
        public News createFromParcel(Parcel source) {
            return new News(source);
        }

        public News[] newArray(int size) {
            return new News[size];
        }
    };
}
